package com.oa.pm.service.impl;

import com.joneying.common.annotation.CommonService;
import com.oa.core.PageResult;
import com.oa.pm.entity.LearningExperienceFile;
import com.oa.pm.mapper.LearningExperienceFileMapper;
import com.oa.pm.service.ILearningExperienceFileService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;

/**
 * <p>
 * 学习经历附件表 服务实现类
 * </p>
 *
 * @author syb123
 * @since 2019-01-22
 */
@Service
public class LearningExperienceFileServiceImpl extends ServiceImpl<LearningExperienceFileMapper, LearningExperienceFile> implements ILearningExperienceFileService {

    private final LearningExperienceFileMapper learningExperienceFileMapper;

    @Autowired
    public LearningExperienceFileServiceImpl(LearningExperienceFileMapper learningExperienceFileMapper) {
        this.learningExperienceFileMapper = learningExperienceFileMapper;
    }

    @Override
    @CommonService
    public PageResult<LearningExperienceFile> findList(Integer pageNum, Integer pageSize) {
        if(pageNum == null){
            List<LearningExperienceFile> list = learningExperienceFileMapper.findList();
            return new PageResult<>(list);
        }else{
            // 当前页，总条数 构造 page 对象
            Page<LearningExperienceFile> page = new Page<>(pageNum, pageSize);
            //查询
            List<LearningExperienceFile> list = learningExperienceFileMapper.findList(page);
            return new PageResult<>(list);
        }
    }

    /**
    * 根据id查询
    */
    @Override
    @CommonService
    public LearningExperienceFile findLearningExperienceFileById(String id){
        return learningExperienceFileMapper.findById(id);
    }
}
